<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    /* var arr = [1 , 2 , 3 ];
    var [a, b , c] = arr;
    console.log(a, b, c); */

    /* var arr = [1 , 2 , 3 , 4 ];
    var [a, b , c] = arr;
    console.log(a, b, c);//1,2,3 */

    /* var arr = [1 , 2 , 3 ];
    var [a, b , c ,d] = arr;
    console.log(a, b, c , d);//1 2 3 undefined */

    /* var arr = [1 , 2 , 3];
    var [a, b , c ,d] = arr;
    d = d == undefined? 0 : d;
    console.log(a, b, c , d);//1 2 3 0 */

    var arr = [1, [2, 3, [4, 5]], 6];
    var [a, [b, c, [d, e]], f] = arr;
    console.log(a, b, c, d, e, f);// 1 2 3 4 5 6

    // 如果等号的右边不是数组（或者严格地说，不是可遍历的结构(数组/伪数组/字符串)），那么将会报错。
    let [foo] = 1;//会报错:    1 is not iterable(iterable   可迭代的)
    // let [foo] = false;
    // let [foo] = NaN;
    // let [foo] = undefined;
    // let [foo] = null;
    // let [foo] = {};
</script>

</html>